<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>用户管理</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/backStyle.css">
<link rel="stylesheet" href="css/style.css"></link>
<link rel="stylesheet" type="text/css" href="css/myButton.css">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap-modal.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>

<style>
html,body {
	height: 100%;
	width: 100%;
	border: 0;
	background: #fff;
	overflow-y: auto;
}

.button {
	margin-top: 1.5em;
	margin-left: 12em;
}

label {
    width: 8em;
}
</style>
</head>
<body>
	<ul class="breadcrumb">
		<li><a href="sys/welcome.jsp">首页</a></li>
		<li class="active"><a href="sys/userManage.jsp">用户管理</a></li>
		<li class="active">用户查看</li>
	</ul>
	<div class="panel panel-default">
		<div class="panel-body">
			<div class="form">
				<form action="userManageEdit.action" id="userInfor">
					<input name="user.id" type="hidden" value="<s:property value="user.id"/>">
					<p>
						<label>用户名称：</label>
						<span><input type="text" name="user.name" value="<s:property value="user.name"/>"  id="userName"/></span>
						<span class="redstar">*</span>
					</p>
					<p>
						<label>邮箱地址：</label>
						<span><input type="text" name="user.email" value="<s:property value="user.email"/>" id="userEmail"/></span>
					</p>
					<p>
						<label>用户密码：</label>
						<span><input type="password" name="user.password" value="<s:property value="user.password"/>" id="userPassword"/></span>
						<span class="redstar">*</span>
					</p>
					<p>
						<label>确认密码：</label>
						<span><input type="password" value="" id="checkPassword"/></span>
						<span class="redstar">*</span>
					</p>
					<input id="userInforSubmit" type="button" value="保存用户信息" onclick="userInfoCheck()" class="button black">
				</form>
				</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	function userInfoCheck() {
		var userName = $("#userName").val();
		var userPassword = $("#userPassword").val();
		var checkPassword = $("#checkPassword").val();
		if (checkPassword != userPassword) {
			alert("两次输入的密码不一致!");
			$("#userPaassword").focus();
			$("#userPaassword").val("${user.password}");
			return false;
		}
		if (userName.length<1||userName.length>16) {
			alert("请输入不超过16位的用户名");
			document.getElementById("userName").focus();
			$("#userName").val("${user.name}");
			return false;
		}
		if (userPassword.length<1||userPassword.length>16) {
			alert("请输入不超过16位的密码");
			document.getElementById("userPassword").focus();
			$("#userPassword").val("${user.password}");
			return false;
		}
		if (confirm('您是否要保存用户信息？')) {
			$.ajax({
				url : "userManageEdit.action",
				type : "post",
				dataType : "json",
				data : $("#userInfor").serialize(),
				success : function(data) {
					var flag = JSON.parse(data).flag;
					if (flag == "success") {
						alert("保存用户信息成功！");
						window.location.href = "sys/userManage.jsp";
					} else {
						alert("保存用户信息失败！");
					}
				}
			});
		} else {
			return false;
		}
	}
</script>
</html>
